package com.ti.demo.observation;

import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.observation.ToolCallingObservationContext;
import org.springframework.stereotype.Component;

/**
 * @description: com.ti.demo.observation
 * @Author Triagen
 * @Date 2025/10/27 10:03
 */
@Slf4j
@Component
public class ToolCallingContentObservationHandler implements ObservationHandler<ToolCallingObservationContext> {

    @Override
    public void onStart(ToolCallingObservationContext context) {
        log.info("Tool Calling arguments:\n{}", context.getToolCallArguments());
    }

    @Override
    public void onStop(ToolCallingObservationContext context) {
        log.info("Tool Calling result:\n{}", context.getToolCallResult());
    }

    @Override
    public boolean supportsContext(Observation.Context context) {
        return context instanceof ToolCallingObservationContext;
    }
}
